<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title> {$action} | {:get_opinion('title')}</title>

    <include file="Public:head"/>

    <link href="__PUBLIC__/AdminLTE/css/timepicker/jquery-ui-1.8.17.custom.css" rel="stylesheet"/>
    <link href="__PUBLIC__/AdminLTE/css/timepicker/jquery-ui-timepicker-addon.css" rel="stylesheet"/>

    <script type="text/javascript">
        window.UEDITOR_HOME_URL = "__ROOT__/Extend/Ueditor/";

        var post_id = '{$post_id}';

        var URL_upload = "{$URL_upload}";
        var URL_fileUp = "{$URL_fileUp}";
        var URL_scrawlUp = "{$URL_scrawlUp}";
        var URL_getRemoteImage = "{$URL_getRemoteImage}";
        var URL_imageManager = "{$URL_imageManager}";
        var URL_imageUp = "{$URL_imageUp}";
        var URL_getMovie = "{$URL_getMovie}";
        var URL_home = "{$URL_home}";

    </script>

    <style>

        .form-group .controls {

            margin-left: 80px;
        }

        .form-group .control-label {

            width: 60px;

        }

        p {
            text-indent: 28px;
        }

    </style>

    <load href="__ROOT__/Extend/Ueditor/ueditor.config.js"/>
    <load href="__ROOT__/Extend/Ueditor/ueditor.all.js"/>
</head>
<body class="skin-blue">

{:W('Common/header')}

<div class="wrapper row-offcanvas row-offcanvas-left">
{:W('Common/sideMenu')}


<!-- Right side column. Contains the navbar and content of the page -->
<aside class="right-side">
<!-- Content Header (Page header) -->


<section class="content-header">
    <h1>
        {$action}
        <small>{:get_opinion('title')}</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="{$module_url}"><i class="fa fa-dashboard"></i> {$module}</a></li>
        <li class="active">{$action}</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">

<div class="row">
<div class="col-md-12">

<!-- /.box-header -->
<div class="box-body">


<form action="{$handle}" id="add_post"
      name="add_post" class="form-horizontal">


<div class="form-group">
    <label class="control-label">标题</label>

    <div class="controls">
        <input type="text" id="post_title"
               class="form-control large" name="post_title"
               value="{$info.post_title}"/>
                                    <span class="help-inline" style="color: #d73726">
                                      当前类型:{$info['post_status']}
                                    </span>

    </div>
</div>
<div class="form-group">
    <label class="control-label">内容</label>

    <div class="controls">

        <textarea class="span12 ckeditor" id="post_content" name="post_content" title="">
            {$info.post_content}
        </textarea>

    </div>

</div>

<div class="form-group">

    <label class="control-label">分类</label>

    <div class="controls">
        <div class="btn-group">
            <a class="btn btn-danger" href="#" data-toggle="dropdown" style="width: 300px;">
                选择分类 <i class="icon-angle-down"></i>
            </a>

            <div class="dropdown-menu hold-on-click dropdown-checkboxes"
                 style="width: 400px;height: 300px;overflow: scroll">
                <foreach name="cats" item="vCats">
                    <div><label><input
                            type="checkbox" value="{$vCats.cat_id}" name="cats[]"
                        <foreach name="info['post_cat']" item="pcs">
                            <if condition="$vCats['cat_id'] eq $pcs['cat_id']">
                                checked="checked"
                                <else/>
                            </if>
                        </foreach>
                        /> {$vCats.cat_slug}
                    </label>
                    </div>
                </foreach>
            </div>
        </div>


    </div>
</div>

<!--<control access="Admin/Posts/NOVERIFY">

    <div class="form-group">

        <label class="control-label">标签</label>

        <div class="controls">

            <div class="btn-group">
                <a class="btn btn-primary" href="#" data-toggle="dropdown"
                   style="width: 300px;">
                    选择标签 <i class="icon-angle-down"></i>
                </a>

                <div class="dropdown-menu hold-on-click dropdown-checkboxes"
                     style="width: 500px;height: 300px;overflow: scroll">

                    <foreach name="tags" item="vTags" key="k"><input
                            type="checkbox" value="{$vTags.tag_id}" name="tags[]"
                        <foreach name="info['post_tag']" item="pts">
                            <if condition="$vTags['tag_id'] eq $pts['tag_id']">
                                checked="checked"
                                <else/>
                            </if>
                        </foreach>
                        /> {$vTags.tag_name}&nbsp;&nbsp;

                        <php>
                            if($k%5==0){
                            echo '<br/>';
                            }

                        </php>

                    </foreach>

                </div>
            </div>
        </div>
    </div>


</control>-->



<div id="post_advance">


    <div class="form-group">
        <label class="control-label">类型</label>

        <div class="controls">


            <select class="small form-control" tabindex="1" name="post_type" id="post_type">

                {$post_type}

            </select>
            <span class="help-inline"></span>


        </div>

    </div>

    <div class="form-group">
        <label class="control-label">状态</label>

        <div class="controls">


            <select class="small form-control" tabindex="1" name="post_status" id="post_status">

                {$post_status}

            </select>
            <span class="help-inline"></span>


        </div>

    </div>


    <div class="form-group">
        <label class="control-label">模板</label>

        <div class="controls">


            <select class="small form-control" tabindex="1" name="post_template"
                    id="post_template">

                {$tpl_type}

            </select>
            <span class="help-inline"></span>


        </div>

    </div>

    <div class="form-group">
        <label class="control-label">置顶</label>

        <div class="controls">

            <label class="radio">
                <div class="radio">


                    <if condition="$info.post_top eq 1 ">
									<span class="checked"><input type="radio"
                                                                 name="post_top" value="1" checked=""></span>
                        <else/>
									<span class=""><input type="radio"
                                                          name="post_top" value="1"></span>

                    </if>

                </div>
                是
            </label>

            <label class="radio">
                <div class="radio">


                    <if condition="$info.post_top eq 0 ">
										<span class="checked"><input type="radio"
                                                                     name="post_top" value="0" checked=""></span>
                        <else/>
										<span class=""><input type="radio"
                                                              name="post_top" value="0"></span>
                    </if>


                </div>
                否
            </label>


        </div>
    </div>

    <div class="form-group">
        <label class="control-label">发布时间:</label>

        <div class="input-group controls " style="width: 40%">
            <input name="post_date" type="text" class="form-control timepicker"
                   style="z-index:2"
                   value="{$info.post_date}"/>

            <div class="input-group-addon">
                <i class="fa fa-clock-o"></i>
            </div>
        </div>
        <!-- /.input group -->
    </div>

    <!--<div class="form-group">
        <label class="control-label">修改时间:</label>

        <div class="input-group controls " style="width: 40%">

            <input name="post_modified" type="text" class="form-control timepicker"
                   style="z-index:2"
                   value=""/>

            <div class="input-group-addon">
                <i class="fa fa-clock-o"></i>
            </div>
        </div>
    </div>-->


</div>


<input type="hidden" name="post_id" value="{$post_id}"/>

<div class="form-actions">
    <span style="font-size: 18px; color: red; font-weight: bold;" id="success"></span>

    <!--<control access="Admin/Posts/NOVERIFY">
        <button type="button" id="post_vertify_ctl" class="btn">
            <i class="icon-ok"></i> 审核通过
        </button>
    </control>


    <button type="button" id="post_width_ctl" class="btn btn-warning">
        <i class="icon-ok"></i> 沉浸模式
    </button>

    <button type="button" id="post_advance_ctl" class="btn btn-primary">
        <i class="icon-ok"></i> 高级选项
    </button>-->

    <button type="button" id="post_submit_ctl" class="btn btn-info submit">
        <i class="icon-ok"></i> 提交
    </button>


</div>

</form>


</div>


</div>
</div>


</section>
<!-- /.content -->
</aside>
<!-- /.right-side -->
</div>
<!-- ./wrapper -->


<include file="Public:foot"/>
<script type="text/javascript" src="__PUBLIC__/share/js/functions.js"></script>
<script type="text/javascript" src="__PUBLIC__/share/js/jquery.form.js"></script>


<script type="text/javascript" src="__PUBLIC__/share/js/jquery-ui-1.10.4.min.js"></script>
<!--<script type="text/javascript" src="__PUBLIC__/share/js/jquery-ui-1.8.18.min.js"></script>-->

<script type="text/javascript"
        src="__PUBLIC__/AdminLTE/js/plugins/timepicker/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript"
        src="__PUBLIC__/AdminLTE/js/plugins/timepicker/jquery-ui-timepicker-zh-CN.js"></script>

<script type="text/javascript">

    function leave_confirm() {
        if (true) {
            return "确认离开将不会保存当前数据。";
        }
    }

    $(window).bind('beforeunload', leave_confirm);


    $(document).ready(function () {


        $("#post_advance_ctl").click(function () {
            var post_advance = $("#post_advance");
            post_advance.slideToggle(200);
        });

        $("#post_vertify_ctl").click(function () {
            $("#post_status").val("");
            $("#post_status").val("publish");
            $("#post_status").find("option[value='unverified']").attr("selected", false);
            $("#post_status").find("option[value='reverify']").attr("selected", false);
            $("#post_status").find("option[value='draft']").attr("selected", false);
            $("#post_status").find("option[value='publish']").attr("selected", true);

            $('#post_submit_ctl').click();

        });


        $("#post_width_ctl").click(function () {
            $(".sidebar-toggle").trigger("click");
        });

    });

    $(function () {


        var editor;
        //具体参数配置在  editor_config.js  中
        var options = {
            zIndex: 999,

            initialFrameWidth: "95%", //初化宽度
            initialFrameHeight: 400, //初化高度
            focus: false, //初始化时，是否让编辑器获得焦点true或false
            maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign'
            , //允许的最大字符数 'fullscreen',
            pasteplain: true, autoHeightEnabled: false,
            autotypeset: {
                mergeEmptyline: true,         //合并空行
                removeClass: true,           //去掉冗余的class
                removeEmptyline: false,      //去掉空行
                textAlign: "left",           //段落的排版方式，可以是 left,right,center,justify 去掉这个属性表示不执行排版
                imageBlockLine: 'center',      //图片的浮动方式，独占一行剧中,左右浮动，默认: center,left,right,none 去掉这个属性表示不执行排版
                pasteFilter: false,            //根据规则过滤没事粘贴进来的内容
                clearFontSize: false,          //去掉所有的内嵌字号，使用编辑器默认的字号
                clearFontFamily: false,        //去掉所有的内嵌字体，使用编辑器默认的字体
                removeEmptyNode: false,       // 去掉空节点
                                              //可以去掉的标签
                removeTagNames: {"font": 1},
                indent: false,                 // 行首缩进
                indentValue: '0em'             //行首缩进的大小
            },
            toolbars: [
                ['fullscreen', 'source', '|', 'undo', 'redo',
                    '|', 'bold', 'italic', 'underline', 'fontborder',
                    'strikethrough', 'superscript', 'subscript',
                    'removeformat', 'formatmatch', 'autotypeset',
                    'blockquote', 'pasteplain', '|', 'forecolor',
                    'backcolor', 'insertorderedlist',
                    'insertunorderedlist', 'selectall', 'cleardoc', '|',
                    'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                    'customstyle', 'paragraph', 'fontfamily', 'fontsize',
                    '|', 'directionalityltr', 'directionalityrtl',
                    'indent', '|', 'justifyleft', 'justifycenter',
                    'justifyright', 'justifyjustify', '|', 'touppercase',
                    'tolowercase', '|', 'link', 'unlink', 'anchor', '|',
                    'imagenone', 'imageleft', 'imageright', 'imagecenter',
                    '|', 'insertimage', 'emotion', 'insertvideo',
                    'attachment', 'map', 'gmap', 'insertframe',
                    'insertcode', 'webapp', 'pagebreak', 'template',
                    'background', '|', 'horizontal', 'date', 'time',
                    'spechars', 'wordimage', '|',
                    'inserttable', 'deletetable',
                    'insertparagraphbeforetable', 'insertrow', 'deleterow',
                    'insertcol', 'deletecol', 'mergecells', 'mergeright',
                    'mergedown', 'splittocells', 'splittorows',
                    'splittocols', '|', 'print', 'preview', 'searchreplace']
            ]

        };
        editor = new UE.ui.Editor(options);
        editor.render("post_content");
        /*editor.ready(function(){
         editor.setContent('{$v.content}');
         });*/

        $(".submit").click(
                function () {

                    if (editor.hasContents()) {
                        editor.sync();
                    }

                    var div = $("#success");
                    if ($("#post_title").val() == '' ||
                            $("#post_title").val() == '未命名' ||
                            $("#post_content").val() == '') {
                        div.fadeIn().html("标题或内容不能为空");
                        alert('标题或内容不能为空');
                        div.fadeOut(5000);
                        return false;
                    }

                    var arr = [];

                    $("input[name='cats[]']:checked").each(function (i, o) {
//                        a[i] = $(o).val();
                        arr.push($(o).val());
                    });

                    if (arr.length == 0) {
                        div.fadeIn().html("分类信息不能为空<br />请选择分类");
                        div.fadeOut(5000);
                        return false;
                    }

                    var url = '{$handle}';
                    var formObj = $("#add_post");
                    formObj.ajaxSubmit({
                        url: url,
                        type: "POST",
                        dataType: "json",
                        success: function (data) {
                            $(window).unbind('beforeunload', leave_confirm);

                            if (data.status == 1) {
                                $(".submit").hide();
                                div.fadeIn().html(data.info);
                                div.fadeOut(5000);

                            } else {
                                div.fadeIn().html(data.info);
                                div.fadeOut(5000);
                            }
                            if (data.url && data.url != '') {
                                setTimeout(function () {
                                    top.window.location.href = data.url;
                                }, 2000);
                            }
                            if (data.url == '') {
                                setTimeout(function () {
                                    top.window.location.reload();
                                }, 2000);
                            }

                        }
                    });
                });

        $(".timepicker").datetimepicker({
            //showOn: "button",
            //buttonImage: "./css/images/icon_calendar.gif",
            //buttonImageOnly: true,
            showSecond: true,
            timeFormat: 'hh:mm:ss',
            stepHour: 1,
            stepMinute: 1,
            stepSecond: 1

        });
    });


</script>


</body>
</html>